const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const config = {
  entry: {
    // wbx: './src/wbx.js',
    // wbxShell: './src/wbx.shell.js',
    // wbxModel: './src/wbx.model.js',
    // wbxGrid: './src/wbx.grid.js',
    app: './src/app.js',
    vendors: './node_modules/jquery/dist/jquery.min.js'
  },
  devtool: 'inline-source-map',
  devServer: {
    contentBase: path.resolve(__dirname, 'dist'),
    // compress: true,
    port: 7879
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({template: './src/test.html'}),
    new CopyWebpackPlugin([
      { from: 'src/wbx.js', to: 'wbx.js' },
      { from: 'src/wbx.shell.js', to: 'wbx.shell.js' },
      { from: 'src/wbx.model.js', to: 'wbx.model.js' },
      { from: 'src/wbx.util.js', to: 'wbx.util.js' },
      { from: 'src/wbx.grid.js', to: 'wbx.grid.js' },
      { from: 'src/wbx.grid.firstblock.js', to: 'wbx.grid.firstblock.js' },
      { from: 'src/wbx.grid.header.js', to: 'wbx.grid.header.js' },
      { from: 'src/wbx.grid.body.js', to: 'wbx.grid.body.js' },
      { from: 'src/wbx.grid.menu.js', to: 'wbx.grid.menu.js' }
      // { from: 'src/wbx.grid.js', to: 'wbx.grid.js' }
    ])
  ]
};

module.exports = config;